package com.ssy.lingxi.order.model.constant;

import java.util.Arrays;

/**
 * 订单服务内部消息队列类型
 * @author 万宁
 * @version 2.0.0
 * @date 2021-12-31
 */
public enum OrderQueueMessageTypeEnum {
    /**
     * 订单自动取消 - 1
     */
    AUTO_CANCEL(1, "自动取消订单"),

    /**
     * 自动收货延迟队列 - 2
     */
    AUTO_RECEIVE(2, "订单自动收货"),

    /**
     * 支付结果查询 - 3
     */
    PAYMENT_QUERY(3, "支付结果查询"),

    /**
     * 未知类型
     */
    UNKNOWN(99, "未知");

    OrderQueueMessageTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;
    private String name;

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static OrderQueueMessageTypeEnum parse(Integer code) {
        return code == null ? null : Arrays.stream(OrderQueueMessageTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(UNKNOWN);
    }
}
